home *** CD-ROM | disk | FTP | other *** search
- /* -*-C-*-
- ********************************************************************************
- *
- * File: wc_Form.c
- * RCS: $Header: wc_Form.c,v 1.3 91/03/14 03:14:41 mayer Exp $
- * Description: XM_FORM_WIDGET_CLASS
- * Author: Niels Mayer, HPLabs
- * Created: Fri Oct 27 22:35:52 1989
- * Modified: Thu Oct 3 21:52:59 1991 (Niels Mayer) mayer@hplnpm
- * Language: C
- * Package: N/A
- * Status: X11r5 contrib tape release
- *
- * WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
- * XLISP version 2.1, Copyright (c) 1989, by David Betz.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Hewlett-Packard and David Betz not be
- * used in advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission. Hewlett-Packard and David Betz
- * make no representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- * HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
- * IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * See ./winterp/COPYRIGHT for information on contacting the authors.
- *
- * Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
- * Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
- *
- ********************************************************************************
- */
- static char rcs_identity[] = "@(#)$Header: wc_Form.c,v 1.3 91/03/14 03:14:41 mayer Exp $";
-
- #include <stdio.h>
- #include <Xm/Xm.h>
- #include <Xm/Form.h>
- #include "winterp.h"
- #include "user_prefs.h"
- #include "xlisp/xlisp.h"
- #include "w_funtab.h"
-
-
- extern Widget Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(); /* w_classes.c */
-
-
- /*****************************************************************************
- * (send XM_FORM_WIDGET_CLASS :new
- * [:managed/:unmanaged]
- * [:dialog]
- * [<name>]
- * <parent>
- * [:XMN_<arg1> <val1>]
- * [. . . ]
- * [:XMN_<argN> <valN>])
- *
- * The optional keyword submessage :managed will cause a subsequent call
- * to XtManageChild(). If the submessage :unmanaged is present, or no
- * submessage, then XtManageChild() won't be called, and the resulting
- * widget will be returned unmanaged.
- *
- * (send XM_FORM_WIDGET_CLASS :new ...)
- * --> XmCreateForm();
- * (send XM_FORM_WIDGET_CLASS :new :dialog ...)
- * --> XmCreateFormDialog();
- ****************************************************************************/
- LVAL Xm_Form_Widget_Class_Method_ISNEW()
- {
- extern ArgList Wres_Get_LispArglist(); /* from w_resources.c */
- extern void Wres_Free_C_Arglist_Data(); /* from w_resources.c */
- extern LVAL k_managed, k_unmanaged, k_dialog;
- LVAL self, o_parent;
- char* name;
- Boolean managed_p, dialog_p;
- Widget parent_widget_id, widget_id;
-
- self = xlgaobject(); /* NOTE: xlobj.c:clnew() returns an OBJECT; if this method
- returns successfully, it will return a WIDGETOBJ */
-
- /* get optional managed/unmanaged arg */
- if (moreargs() && ((*xlargv == k_managed) || (*xlargv == k_unmanaged)))
- managed_p = (nextarg() == k_managed);
- else
- managed_p = FALSE; /* by default don't call XtManageChild() */
-
- /* get optional :dialog arg */
- if (moreargs() && (*xlargv == k_dialog)) {
- nextarg();
- dialog_p = TRUE;
- }
- else
- dialog_p = FALSE; /* by default, we don't want a dialog widget */
-
- /* get optional <name> arg */
- if (moreargs() && (stringp(*xlargv)))
- name = (char*) getstring(nextarg());
- else
- name = ""; /* default name */
-
- /* get required <parent> widget-object arg */
- parent_widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&o_parent);
-
- /*
- * Store the widget object <self> in the XmNuserData resource on the
- * widget. This will allow us to retrieve the widget object from Xtoolkit
- * functions returning widget ID's without having to keep around a table
- * of widgetID-->widget-objects.
- */
- ARGLIST_RESET(); ARGLIST_ADD(XmNuserData, (XtArgVal) self);
-
- if (moreargs()) { /* if there are more arguments, */
- Cardinal xt_numargs; /* then we have some extra widget resources to set */
- ArgList xt_arglist = Wres_Get_LispArglist(self, parent_widget_id, ARGLIST(), &xt_numargs);
- if (dialog_p)
- widget_id = XmCreateFormDialog(parent_widget_id, name, xt_arglist, xt_numargs);
- else
- widget_id = XmCreateForm(parent_widget_id, name, xt_arglist, xt_numargs);
- Wres_Free_C_Arglist_Data();
- }
- else
- if (dialog_p)
- widget_id = XmCreateFormDialog(parent_widget_id, name, ARGLIST());
- else
- widget_id = XmCreateForm(parent_widget_id, name, ARGLIST());
-
- Wcls_Initialize_WIDGETOBJ(self, widget_id);
-
- if (managed_p)
- XtManageChild(widget_id);
-
- #ifdef DEBUG_WINTERP_1
- Wcls_Print_WidgetObj_Info(self);
- #endif
- return (self);
- }
-
-
- /******************************************************************************
- *
- ******************************************************************************/
- Wc_Form_Init()
- {
- LVAL o_XM_FORM_WIDGET_CLASS;
- extern LVAL Wcls_Create_Subclass_Of_WIDGET_CLASS(); /* w_classes.c */
- extern xladdmsg(); /* from xlobj.c */
-
- o_XM_FORM_WIDGET_CLASS =
- Wcls_Create_Subclass_Of_WIDGET_CLASS("XM_FORM_WIDGET_CLASS",
- xmFormWidgetClass);
-
- /* a special :isnew method on this class allows for the creation of this
- widget in a popup dialog if the submessage keyword :dialog is given ... */
- xladdmsg(o_XM_FORM_WIDGET_CLASS, ":ISNEW",
- FTAB_Xm_Form_Widget_Class_Method_ISNEW);
- }
-